package cn.echoedu.dao.mydb;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import cn.echoedu.dao.DAODelete;
import cn.echoedu.dao.DAOFactory;
import cn.echoedu.dao.DAOInsert;
import cn.echoedu.dao.DAORead;
import cn.echoedu.dao.DAOUpdate;

public abstract class AbstractBaseDao implements BaseDao{
	private DAOFactory createDaoFactory(){
		return DAOFactory.factoryProducer(Databases.MySql);
	}
	protected DAOInsert createDaoInsert() throws SQLException{
		return createDaoFactory().getDAOInsert();
	}
	protected DAODelete createDaoDelete(){
		return createDaoFactory().getDAODelete();
	}
	
	protected  DAOUpdate createDaoUpdate(){
		return createDaoFactory().getDAOUpdate();
	}
	protected DAORead createDaoRead() throws SQLException{
		return createDaoFactory().getDAORead();
	}
	public abstract <T> boolean putInfo(Connection con,TableName tableName,T 
			  currentPojo,boolean running) throws SQLException;
	  
	  public abstract<T> boolean deleteFrom(Connection con,TableName tablename,T
			  currentPojo) throws SQLException;
   
	  public abstract <T> boolean updateInfo(Connection con,TableName tableName,T oldPojo,
			  T currentPojo) throws SQLException;

	  public abstract <T> List<T> getAll(Connection con,TableName tableName)throws
	   SQLException;
	  
	  public abstract <T> List<T> getAllForInput(Connection con,TableName tableName,
			  String columnName,String searchValue) throws SQLException;
	  
	  public abstract <T> T getPojoForPrimarKey(Connection con,TableName tableName,
			  String primaryKey) throws SQLException;
	  
	  public abstract <T> boolean alreadyExisting(Connection con,TableName tableName,
			  String primaryKey) throws SQLException;
	  
	  public abstract <T> boolean alreadyExisting(Connection con,TableName tableName,
			  T currentPojo) throws SQLException;
	  public abstract <T> List<T> getPojoForLeftJoinAndColumn(Connection con,
			TableName lefttablename, TableName righttablename,
			String leftcolumn, String rightcolumn, String column, String value,String orderbysql)
			throws SQLException;

}
